#ifndef JONO_ENGINE_H
#define JONO_ENGINE_H

#include <QMainWindow>
#include <QImage>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QTimer>
#include <QElapsedTimer>
#include <QGraphicsPixmapItem>


#include "vga.h"
#include "keyboard.h"
#include "game_main.h"
#include "qt/qt_sound.h"


class Engine: public QMainWindow {
    Q_OBJECT

public:
    Engine(QWidget* parent = nullptr);
    ~Engine();

    const char* getKeyboard();

    void* getFrameBuffer();
    void swapFrameBuffer();

private:
    QGraphicsScene* m_scene;
    QGraphicsView* m_view;
    QTimer* m_timer;
    QPixmap* m_pixmap;
    QImage* m_image;
    QGraphicsPixmapItem* m_pixmapItem;
    QElapsedTimer* m_elapsedTimer;

    qint64 m_elapsed;

    unsigned char* m_data;

    unsigned int m_width, m_height;
    float m_scale;

    std::vector<SoundSystem*> m_soundSystems;

protected:
    void keyPressEvent(QKeyEvent* event);
    void keyReleaseEvent(QKeyEvent* event);


public slots:
    unsigned char getKeyCode(QKeyEvent* event);
    void update();
};

#endif // JONO_ENGINE_H
